package Day07;
/*
1.1输出所有的水仙花数，所谓水仙花数是指一个3位数，其每位数字立方和等于其本身
，如153 = 1*1*1 + 3*3*3 + 5*5*5=1+27+125

1.三位数的范围100-999
2.水仙花数的条件，有一个数字number
        number=number百位的立方+number十位的立方+number个位的立方=number
 */
public class LoopDemo01 {
    public static void main(String[] args) {

/*        int number=153;
        //1.获取了该数的每位数字
        int ge=number%10;
        int shi=number/10%10;
        int bai=number/100;
        System.out.println(ge+" "+shi+" "+bai);

        //2.number百位的立方+十位数的立方+个位的立方==number
        if(ge*ge*ge+bai*bai*bai+shi*shi*shi==number){
            System.out.println(number+"是水仙花数");
        }*/

        print();

    }


    public static void print() {
        for (int number = 100; number <= 999; number++) {
            int ge = number % 10;
            int shi = number / 10 % 10;
            int bai = number / 100;

            if (ge * ge * ge + bai * bai * bai + shi * shi * shi == number) {
                System.out.println(number + "是水仙花数");
            }
        }
    }
}